@extends('public.father')
@section('content')
    <div class="container">
        <form action="{{route('blog.store')}}" method="post">
        @csrf
            <div class="card">
            <div class="card-header">
                发布文章
            </div>
            <div class="card-block">
                <div class="form-group">
                    <label for="exampleInputEmail1">标题</label>
                    <input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="请输入文章标题" name="title">
                </div>
                <div class="form-group">
                    <label for="exampleInputPassword1">内容</label>
                    <textarea name="content" id="" class="form-control" cols="30" rows="10"></textarea>
                </div>
            </div>
            <div class="card-footer text-muted">
                <button type="submit" class="btn btn-primary">发布</button>
            </div>
        </div>
        </form>
        <table class="table">
            <thead>
            <tr>
                <th>编号</th>
                <th>标题</th>
                <th>作者</th>
                <th>发布时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            @foreach($blogs as $blog)
            <tr>
                <td scope="row">{{$blog['id']}}</td>
                <td>{{$blog['title']}}</td>
                <td>{{$blog->user->name}}</td>
                <td>{{$blog['created_at']}}</td>
                <td>
                    <div class="btn-group" role="group" aria-label="Basic example">
                        @can('update',$blog)
                        <a href="{{route('blog.edit',$blog)}}" class="btn btn-success">编辑</a>
                        <form action="{{route('blog.destroy',$blog->id)}}" method="post">
                            @csrf
                            @method('delete')
                        <button type="submit" class="btn btn-danger">删除</button>
                        </form>
                            @endcan
                    </div>
                </td>
            </tr>
            @endforeach
            </tbody>
        </table>
        {{$blogs->links()}}
    </div>
@endsection